home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_02_05
/
2n05064d
< prev
next >
Wrap
Text File
|
1991-03-25
|
375b
|
23 lines
int *binsearch(int x, const int v[], size_t n)
{
size_t low = 0;
size_t high = n;
int mid;
while (low < high)
{
mid = (low + high) / 2;
if (x < v[mid])
high = mid;
else if (x > v[mid])
low = mid + 1;
else
return &v[mid];
}
return 0;
};